class OrderMaintainPartsController < ApplicationController
  def new
  	@order_maintain_part = OrderMaintainPart.new
    @part_styles = PartStyle.all
  end

  def create
  	@order_maintain_part = OrderMaintainPart.new post_params
    if @order_maintain_part.save
       redirect_to order_maintain_path(:id =>@order_maintain_part.order_maintain.id)
    else
      render :action => 'new'
    end
  end

  def destroy
    @order_maintain_part = OrderMaintainPart.find params[:id]
    @order_maintain_part.destroy
    redirect_to order_maintain_path(:id =>@order_maintain_part.order_maintain.id)
  end

   def post_params
    params.require(:order_maintain_part).permit(*%w(order_maintain_id part_id part_style_id qty))
  end
end
